<!--suppress ALL -->
<template>
    <div class="sidebar">
        <el-menu :default-active="onRoutes" class="el-menu-vertical-demo" theme="dark" unique-opened router>
            <template v-for="item in items">
                <template v-if="item.subs">
                    <el-submenu :index="item.index">
                        <template slot="title"><i :class="item.icon"></i>{{ item.title }}</template>
                        <el-menu-item v-for="(subItem,i) in item.subs" :key="i" :index="subItem.index">{{ subItem.title }}
                        </el-menu-item>
                    </el-submenu>
                </template>
                <template v-else>
                    <el-menu-item :index="item.index">
                        <i :class="item.icon"></i>{{ item.title }}
                    </el-menu-item>
                </template>
            </template>
        </el-menu>
    </div>
</template>

<script>
    export default {
        data() {
            return {
                items: [
                    {
                        icon: 'el-icon-menu',
                        index: 'readme',
                        title: '关于实验室'
                    },
                    {
                        icon: 'el-icon-setting',
                        index: '12',
                        title: '实验室管理',
                        subs:[
                            {
                                icon: 'el-icon-setting',
                                index: 'laboratoryinformation',
                                title: '实验室详情',
                            },
                            {
                                icon: 'el-icon-setting',
                                index: 'laboratory',
                                title: '实验室管理',
                            }
                        ]

                    },
                    {
                        icon: 'el-icon-setting',
                        index: '34',
                        title: '设备管理',
                        subs:[
                            {
                                icon: 'el-icon-setting',
                                index: 'equipmentinformation',
                                title: '设备详情',
                            },
                            {
                                icon: 'el-icon-setting',
                                index: 'equipment',
                                title: '设备管理',
                            }
                        ]
                    },
                    {
                        icon: 'el-icon-setting',
                        index:'20',
                        title: '日常管理',
                        subs:[
                            {
                                icon: 'el-icon-upload2',
                                index: 'epurepairtotle',
                                title: '报修汇总'
                            },
                            {
                                icon: 'el-icon-upload2',
                                index: 'health',
                                title: '卫生汇总'
                            },
                            {
                                icon: 'el-icon-upload2',
                                index: 'classroom_information',
                                title: '教室申请汇总'
                            },
                        ]
                    },
                    {
                        icon: 'el-icon-setting',
                        index:'40',
                        title: '系统管理',
                        subs:[
                            {
                                icon: 'el-icon-setting',
                                index: 'usertable',
                                title: '用户管理',
                            },
                            {
                                icon: 'el-icon-setting',
                                index: 'roletable',
                                title: '角色管理',
                            },
                            {
                                icon: 'el-icon-menu',
                                index: 'resource',
                                title: '资源管理',
                            },
                        ]
                    },
                    {
                        icon: 'el-icon-menu',
                        index: 'help',
                        title: '帮助'
                    },
                    {
                        icon:'el-icon-menu',
                        index:'usual',
                        title:'报修',
                    }
                ]
            }
        },
        computed:{
            onRoutes(){
                return this.$route.path.replace('/','');
            }
        }
    }
</script>

<style scoped>
    .sidebar{
        display: block;
        position: absolute;
        width: 250px;
        left: 0;
        top: 70px;
        bottom:0;
        background: #2E363F;
    }
    .sidebar > ul {
        height:100%;
    }
    .el-menu-vertical-demo{
        background: linear-gradient(to bottom,#485563,#29323c);
    }
</style>
